package ferp.android.tasks.local;

import ferp.android.activities.Ferp;
import ferp.android.services.IResolverService2;
import ferp.android.services.ServiceException;
import ferp.android.services.ServiceProxy;

/**
 * User: olegs
 * Date: 2/6/13 5:23 PM
 */
public class TaskPreallocator extends TaskSerial<Void, ServiceException>
{
  public TaskPreallocator(Ferp ferp, IResolverService2 service)
  {
    super(ferp);

    this.service = service;
  }

  @Override
  protected ServiceException doInBackground(Void... voids)
  {
    try
    {
      ServiceProxy.preallocate(service);

      return null;
    }
    catch (ServiceException e)
    {
      return e;
    }
  }

  @Override
  protected void doOnPostExecute(ServiceException e)
  {
    if (e != null)
      ferp().exit(e);
  }

  private final IResolverService2 service;
}
